```{r include = FALSE}
theme_set(
  theme_bw() +
    theme(#axis.title = element_text(size = 14),
          #axis.text  = element_text(size = 12),
          axis.title.x = element_blank(),
          axis.text.x = element_text(size = 8),
          legend.title = element_blank(),
          legend.text  = element_text(size = 10),
          panel.grid = element_blank())
)
scale_fill_viridis_d <-
  scale_fill_viridis_d(direction = -1, option = "viridis",
                       aesthetics = c("color", "fill"))
```

## Composition
```{r}
p_composition_bar <-
  ggplot(vbdf) +
  aes(x = year, y = prob_mean, fill = race) +
  geom_col() +
  scale_fill_viridis_d +
  labs(y = "Density")
  # theme(legend.position = c(.95,.95),
  #           legend.justification = c(1,1))

p_composition_bar
```

## Turnout: Pr(turnout | raceariate)
```{r}
p_turnout <-
    ggplot(vbdf) +
    aes(x = year, y = pr_turnout_mean, group = race,
        color = race) +
    geom_hline(yintercept = 0.5, color = "grey50") +
    geom_line(size = 1.5) +
    geom_ribbon(aes(ymin = pr_turnout_low, ymax = pr_turnout_high,
                    fill = race, color = NULL), alpha = 0.25) +
    coord_cartesian(ylim = c(0, 1)) +
    scale_fill_viridis_d +
    labs(y = "Turnout")

p_turnout
```

## Vote choice: Pr(vote | raceariate, turnout)

```{r}
p_vote <-
    ggplot(vbdf) +
    aes(x = year, group = race) +

    geom_line(aes(y = pr_voterep_mean, color = "Rep")) +
    geom_ribbon(aes(y = pr_voterep_mean, ymin = pr_voterep_low, ymax = pr_voterep_high,
                    fill = "Rep"), alpha = 0.25) +
  
    geom_line(aes(y = pr_votedem_mean, color = "Dem")) +
    geom_ribbon(aes(y = pr_votedem_mean, ymin = pr_votedem_low, ymax = pr_votedem_high,
                    fill = "Dem"), alpha = 0.25) +
  
    geom_hline(yintercept = 0.5, color = "grey50") +

    scale_color_manual(values = c(Dem = "blue", Rep = "red")) +
    scale_fill_manual(values = c(Dem = "blue", Rep = "red")) +
    facet_grid(race ~ .) +
    theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1),
          legend.position = "none") +
    labs(y = "Pr(vote | turnout)")

p_vote
```

## Net Republican votes

```{r}
p_netrep <-
    ggplot(vbdf) +
    aes(x = year, 
        y = net_rep_mean, ymin = net_rep_low, ymax = net_rep_high,
        group = race, color = race) +
    geom_hline(yintercept = 0, color = "grey50") +
    geom_line(size = 1.5) +
    geom_ribbon(aes(fill = race, color = NULL), alpha = 0.25) +
    # coord_cartesian(ylim = c(0, 1)) +
    scale_fill_viridis_d +
    labs(y = "Net Republican Votes")

p_netrep
```


